source 'https://github.com/CocoaPods/Specs.git'
workspace 'WatermelonTester.xcworkspace'

require_relative '../../node_modules/react-native/scripts/react_native_pods'
require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'

target 'WatermelonTester' do
  config = use_native_modules!

  use_react_native!(
    path: '../../node_modules/react-native',
    # hermes_enabled: false
  )

  pod 'React-jsi', path: '../../node_modules/react-native/ReactCommon/jsi', modular_headers: true
  pod 'WatermelonDB', path: '../../'

  # post_install do |installer|
  #   react_native_post_install(installer)
  # end

  target 'WatermelonTesterTests' do
    inherit! :search_paths
    use_frameworks!

    pod 'Nimble',                 '~> 8.1.2'
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # ccache bails out of caching if clang modules are enabled, but this breaks some packages
      # you also have to be careful about PCHs
      # sometimes you might have to manually add a system framework to project Link phase
      # more info: https://pspdfkit.com/blog/2015/ccache-for-fun-and-profit/
      config.build_settings['CC'] ||= ['$(SRCROOT)/../../../scripts/ccache-clang']
      case target.name
      when 'Nimble'
        config.build_settings['CLANG_ENABLE_MODULES'] ||= ['YES']
      else
        config.build_settings['CLANG_ENABLE_MODULES'] ||= ['NO']
      end
    end
  end
end
